package com.tarena.lbs.user.service.impl;

import com.tarena.lbs.base.protocol.model.Result;
import com.tarena.lbs.base.protocol.pager.PageResult;
import com.tarena.lbs.user.dao.repository.UserGroupRepository;
import com.tarena.lbs.user.pojo.param.UserGroupListParam;
import com.tarena.lbs.user.pojo.param.UserGroupParam;
import com.tarena.lbs.user.pojo.vo.UserGroupVO;
import com.tarena.lbs.user.service.UserGroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserGroupServiceImpl implements UserGroupService {
    @Autowired
    private UserGroupRepository userGroupRepository;

    @Override
    public Result<PageResult<UserGroupVO>> pageList(UserGroupListParam userGroupListParam) {
        PageResult<UserGroupVO> userGroupVOPageResult = userGroupRepository.pageList(userGroupListParam);

        return new Result<>(userGroupVOPageResult);
    }

    @Override
    public Result<Void> save(UserGroupParam param) {
        userGroupRepository.save(param);
        return Result.success();
    }

    @Override
    public Result<Void> del(Integer id) {
        userGroupRepository.del(id);
        return Result.success();
    }

    @Override
    public Result<UserGroupVO> detail(Integer id) {
        return userGroupRepository.detail(id);
    }
}
